# coding=utf-8
__author__ = 'liubin'

from project.tools import Base
from sqlalchemy import Column, Integer, String, BigInteger, ForeignKey, Boolean, Text
from sqlalchemy.orm import relationship, backref
from sqlalchemy.sql.expression import text
from project.tools import JsonpickleMixin
from base import BaseModel


class Textile(BaseModel, Base):
    """
    布料表
    最基本的货物设置，布基类
    """
    __tablename__ = 'm_textile'
    # 编码
    #code = Column('code', String(50), nullable=False)
    # 名称
    name = Column('name', String(200), nullable=False, doc=u'名称')

    type = Column('type', String(50), nullable=False, doc=u'类型')
    # 删除标记
    isDeleted = Column('is_deleted', Boolean, server_default=text('FALSE'), doc=u'删除标记')

    __mapper_args__ = {
        'polymorphic_identity':'textile',
        'polymorphic_on':type,
        'with_polymorphic':'*'
    }

    def __init__(self, data=None):
        """
        初始化
        :param data:
        :return:
        """
        if data:
            #self.code = data.get('code')
            self.name = data.get('name')